﻿@using S4Store.Domain
@model S4Store.Models.Actionplan.IndexModel
@{
    ViewBag.Title = "Index";
    Layout = null;
    S4Store.Domain.Administrator CurrentUser = (S4Store.Domain.Administrator)ViewBag.CurrentUser;
}
<style>
    #actionplantable td
    {
        border: 1px solid #B8D0D6;
    }
    #actionplantable table
    {
        border-collapse: collapse;
    }
    #actionplantable table td
    {
        border: 1px solid #ccc;
    }
</style>
<div class="verticalSplitContainer" style="height: 100%;">
    @Html.Action("ReportBar", "Common", Model.BarModel)
    <div ratio="*">
        <div class="pageContent" style="overflow: auto;" ratio="*">
            <table class="table" cellpadding="0" cellspacing="0" id="actionplantable">
                <tr style="background: #E5EDEF">
                    @*<th width="22"><input type="checkbox" group="ids" class="checkboxCtrl"></th>  *@
                    <td width="150">
                        弱项描述
                    </td>
                    <td width="150">
                        改善步骤
                    </td>
                    <td width="654">
                        <h3 style="text-align: center; height: 20px; line-height: 20px;">
                            执行周期</h3>
                        <table cellpadding="0" cellspacing="0" border="0">
                            <tr>
                                @for (int i = 1; i <= Model.BarModel.Month.LastDay(); i++)
                                {
                                    <td style="height: 20px; width: 20px; overflow: hidden; font-size: 10px; padding: 0;
                                        text-align: center; font-weight: normal;">
                                        @i
                                    </td>
                                }
                            </tr>
                        </table>
                    </td>

                        <td width="50">
                            执行人
                        </td>
                    
                        <td width="50">
                            监控人
                        </td>

                </tr>
                @foreach (var m in this.Model.Data)
                {
                    <tr>
                        @* <td style=" text-align:center"><input name="ids" value="@m.Id" type="checkbox"></td>  *@
                        <td style="vertical-align: top">
                            @if (m.Reason != null)
                            {
                                if (m.Reason.Length > 40)
                                {
                                @Html.Raw(m.Reason.Substring(0, 40) + "...")
                                }
                                else
                                {
                                @Html.Raw(m.Reason)
                                }
                            }
                            <a href="@Url.Action("Detail", new { id = m.Id })" target="dialog" title="详细信息" style=" color:Blue; text-decoration:underline">
                                更多</a>
                        </td>
                        <td style="vertical-align: top">
                            @if (m.Content != null)
                            {
                                if (m.Content.Length > 40)
                                {
                                @Html.Raw(m.Content.Substring(0, 40) + "...")
                                }
                                else
                                {
                                @Html.Raw(m.Content)
                                }
                            }
                            <a href="@Url.Action("Detail", new { id = m.Id })" target="dialog" title="详细信息" style=" color:Blue; text-decoration:underline">
                                更多</a>
                        </td>
                        <td>
                            <table cellpadding="0" cellspacing="0" border="0">
                                <tr>
                                    @for (int i = 1; i <= Model.BarModel.Month.LastDay(); i++)
                                    {
                                        var curdate = new DateTime(Model.BarModel.Month.Year, Model.BarModel.Month.Month, i);
                                        <td style="height: 40px; width:20px; overflow:hidden; letter-spacing:-1px; font-size:10px; padding:0; text-align:center; font-weight: normal; background: 
 @if (m.Start <= curdate && m.End >= curdate)
 {
     switch (m.PlanStatusValue)
     {
         case 1:
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           @:#F2765E;cursor:pointer;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           break;
         case 3:
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           @:#F9BE64;cursor:pointer;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           break;
         case 4:
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           @:#84BC5B;cursor:pointer;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           break;
     }
 }
 else
 {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   @:#ffffff;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               }
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              "> @if (m.Start <= curdate && m.End >= curdate)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     if (CurrentUser.Position == S4Store.Domain.Position.AftersalesManager || CurrentUser.Position == S4Store.Domain.Position.SalesManager || CurrentUser.Position == S4Store.Domain.Position.MarketingManager)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     {
                  <a target="dialog" refreshonclose="true" href="@Url.Action("WriteResult", new { id = m.Id, dt = curdate })" style="display:inline-block; width:100%; height:100%;line-height: 40px;" title="填写阶段描述">
                      @if (m.WriteDate.Year == curdate.Year && m.WriteDate.Month == curdate.Month && m.WriteDate.Day == curdate.Day)
                      {
                          <text>√</text>
                      }
                      else
                      {
                          @:&nbsp;
                      }
                      
                  </a>  
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     }
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     if ((CurrentUser.Position == S4Store.Domain.Position.SystemManager || CurrentUser.Position == S4Store.Domain.Position.StoreManager || CurrentUser.Position == S4Store.Domain.Position.GeneralManager) && m.PlanStatusValue == 3)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     {


                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         if (m.WriteDate.Year == curdate.Year && m.WriteDate.Month == curdate.Month && m.WriteDate.Day == curdate.Day)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         {
                          <a target="dialog" refreshonclose="true" href="@Url.Action("ConfirmResult", new { id = m.Id, dt = curdate })" style="display:inline-block; width:100%; height:100%; line-height: 40px;"  title="确认阶段描述">√</a>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         }
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         else
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         {
                          <a href="javascript:;" style="display:inline-block; width:100%; height:100%; line-height: 40px;"  title="确认阶段描述">&nbsp;</a>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         }

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     }
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     if ((CurrentUser.Position == S4Store.Domain.Position.SystemManager || CurrentUser.Position == S4Store.Domain.Position.StoreManager || CurrentUser.Position == S4Store.Domain.Position.GeneralManager) && m.PlanStatusValue == 4)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         if (m.WriteDate.Year == curdate.Year && m.WriteDate.Month == curdate.Month && m.WriteDate.Day == curdate.Day)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         {
                      <a target="dialog" refreshonclose="true" href="@Url.Action("ConfirmResult", new { id = m.Id, dt = curdate })" style="display:inline-block; width:100%; height:100%; line-height: 40px;"  title="查看阶段描述">√</a>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         }
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     }
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 }
                                        </td>
                                    }
                                </tr>
                            </table>
                        </td>
                        
                            <td>@m.AppUser.Name
                            </td>
                        @{
                           var user = m.Store.Administrators.FirstOrDefault(o => o.PositionType == (int)Position.StoreManager && !o.IsClose);
                        }

                        <td>
                            @if (user != null)
                            {
                                <span>@user.Name</span>
                            }
                            
                        </td>

                    </tr>   
				    
                }
            </table>
        </div>
    </div>
</div>
